﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LoLScrape
{
    /// <summary>
    /// Release Manifest Structure
    /// </summary>
    namespace Manifest
    {
        // Header that appears at start of the Manifest
        struct ManifestHeader
        {
            // Magic value used to identify the file type, must be 0x524c534d (RLSM)
            UInt32 intMagic;

            // 1 if this release contains folders, 0 otherwise
            UInt16 intFolders;

            // 1 if this release contains files, 0 otherwise
            UInt16 intFiles;

            // Offset to the String table from the beginning of the file
            UInt32 intStringTableOffset;

            // Four 8-bit values which represent the release folder version number
            UInt16 intReleaseBuild;
            UInt16 intReleaseRevision;
            UInt16 intReleaseMinor;
            UInt16 intReleaseMajor;
        } //end Manifest Header
	
        // Header that appears at the beginning of each of the different segments
        struct SegmentHeader
        {
            // Total number of items contained in the segment
            UInt32 intNumItems;
        } //end SegmentHeader

        // Body of a Folder Structure Segment
        struct FolderSegment
        {
            //Index in the String Table of the folder name
            UInt32 intFolderNameIndex;

            //Index of the first child-folder in this folder
            UInt32 intChildIndex;

            //Number of children-folders in this folder
            UInt32 intNumChildren;

            //Index of the first file in this folder
            UInt32 intDataIndex;

            //Number of files in this folder
            UInt32 intNumFiles;

        } //end FolderSegment

        // Body of a File Information Segment
        struct FileSegment
        {
            //Index Number of this File
            UInt32 intIndex;

            // Four 8-bit values which represent the release folder version number in which this file belongs
            UInt16 intReleaseBuild;
            UInt16 intReleaseRevision;
            UInt16 intReleaseMinor;
            UInt16 intReleaseMajor;

            // 128-bit Hash of File Contents
            UInt64 intHashHead;
            UInt64 intHashTail;

            // File Type (0 = Release, 5 = Managed, etc)
            UInt32 intFileType;

            // Size (in bytes) of the file
            UInt64 intFilesize;

            // 64-bit checksum/hash of file name
            UInt64 inChecksum;
        } //end FileSegment

        // Header that appears at the beginning of the string table
        struct StringTableHeader
        {
            // Total number of items contained in the table
            UInt32 intNumItems;

            // Size/Length of the String Table area
            UInt32 intLength;
        } //end StringTableHeader

    } //end Manifest

} //end LoLScrape
